using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlTypes;

namespace ECommerce.Library
{
    public class CommonUtility
    {
        public static object FilterNull(object value, Type type)
        {
            if (value == DBNull.Value || value == null)
            {
                if (type == typeof(int))
                    return 0;
                else if (type == typeof(double))
                    return 0.0;
                else if (type == typeof(string))
                    return string.Empty;
                else if (type == typeof(DateTime))
                    return SqlDateTime.MinValue.Value;
                else if (type == typeof(decimal))
                    return 0;
                else if (type == typeof(bool))
                    return false;
                else
                    return value;
            }
            else
                return value;
        }
    }
}
